﻿using UnityEngine;
using System.Collections.Generic;
using UnityEngine.EventSystems;

namespace InputSystem
{
    public class InputListenerBase : MonoBehaviour,IInputListener
    {
        public string InputType
        {
            get;set;
        }

        /// <summary>
        /// 检测是否点击到UI
        /// </summary>
        /// <returns></returns>
        public bool IsPointerOverUIObject()//检测是否点击到ui
        {
            if (EventSystem.current != null)
            {
                PointerEventData eventData = new PointerEventData(EventSystem.current);
                eventData.position = new Vector2(Input.mousePosition.x, Input.mousePosition.y);
                List<RaycastResult> result = new List<RaycastResult>();
                EventSystem.current.RaycastAll(eventData, result);
                return result.Count > 0;
            }
            return false;
        }

        void Start()
        {

        }

        // Update is called once per frame
        void Update()
        {

        }
    }
}